//
//  WifiUtils.m
//  Runner
//
//  Created by frank on 2024/5/20.
//

#import <ifaddrs.h>
#import <arpa/inet.h>
#import <SystemConfiguration/CaptiveNetwork.h>
#import "WifiUtils.h"

@implementation WifiUtils

//封装的方法
+ (NSString *)wifiName{
    ///约定 empty 为没有连上 wifi
    NSString *wifiName = @"empty";
    CFArrayRef myArray = CNCopySupportedInterfaces();
    if (myArray != nil) {
        CFDictionaryRef myDict =CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
        if (myDict != nil) {
            NSDictionary *dict = (NSDictionary*)CFBridgingRelease(myDict);
            wifiName = [dict valueForKey:@"SSID"];
        }
    }
    return wifiName;
}
@end
